package disanzifu;

import java.util.Scanner;

public class String2 {
    public static void main(String[] args) {
        System.out.println("请输入你合法的email！");//aaa@ffffes
        Scanner scanner = new Scanner(System.in);
        String email =scanner.next();
        String2.isEmail(email.trim());
    }
    public static void isEmail(String email){
        if (email.indexOf("@")!=-1){//里面有@
            String substring = email.substring(0,email.indexOf("@"));//jjj@jkdf
            if (substring.length()==0){
                System.out.println("非法email，@前面必须要有字符");
            }else{
                String substring1 = email.substring(email.indexOf("@")+1,email.length());
                if (substring1.length()==0){
                    System.out.println("email@后面必须要有字母");
                }else {
                    boolean is =true;
                    for (int i =0;i<substring1.length();i++){
                        if (substring1.charAt(i)=='.'){
                            is =true;
                        }
                    }
                    if (is){
                        System.out.println("恭喜！email合法");
                    }else {
                        System.out.println("非法email，。没有.");
                    }
                }
            }
        }else {
            System.out.println("非法email，没有包含@");
        }
    }
}
